﻿using IntelligentAgriculture.Contracts.Dto.Input;
using IntelligentAgriculture.Contracts.Dto.Output;
using IntelligentAgriculture.Contracts.Interface;
using IntelligentAgriculture.WebAPI.Application.Command.BodyMeasureModel;
using IntelligentAgriculture.WebAPI.Application.Command.BodyMeasureModelCommand;
using IntelligentAgriculture.WebAPI.Application.Command.BreedingWeighCommand;
using IntelligentAgriculture.WebAPI.Application.Command.SheepCommand;
using IntelligentAgriculture.WebAPI.Application.CommandHandler.BodyMeasureModelCommandHandler;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace IntelligentAgriculture.WebAPI.Controllers
{
    /// <summary>
    /// 体尺测定
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class BodyMeasureModelController : ControllerBase
    {
        private readonly IBodyMeasureModelService bodymeasureService;
        private readonly TokenService tokenService;
        private readonly ILogger<BreedingWeighController> logger;
        private readonly IMediator mediator;

        public BodyMeasureModelController(IBodyMeasureModelService bodymeasureService
            , TokenService tokenService
            , ILogger<BreedingWeighController> logger, IMediator mediator)
        {
            this.bodymeasureService = bodymeasureService;
            this.tokenService = tokenService;
            this.logger = logger;
            this.mediator = mediator;

        }


        /// <summary>
        /// 体尺测定列表
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Results<PageOutput<BodyMeasureModelOutPut>>> BodyMeasureModelList(BodyMeasureModelInPut input)
        {
            var command = new BodyMeasureModelQueryCommand(input);
            var roles = await mediator.Send(command);
            return roles;

        }


        /// <summary>
        /// 体尺测定单删批删
        /// </summary>
        /// <param name="ids"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Results<int>> DeleteBodyMeasureModel(params int[] ids)
        {
            var command = new BodyMeasureModelDeleteCommand(ids.ToArray());
            return await mediator.Send(command);
        }



        /// <summary>
        /// 添加体尺测定
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        /// 
        [HttpPost]
        public async Task<Results<int>> AddBodyMeasureModel(BodyMeasureModelCreateCommand command)
        {
            return await mediator.Send(command);
        }


        /// <summary>
        /// 修改体尺测定
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        /// 
        [HttpPost]
        public async Task<Results<int>> UpdateBodyMeasureModel(BodyMeasureModelUpdateCommand command)
        {
            return await mediator.Send(command);
        }




    }





}
